import java.util.Scanner;

/**
 * 动态规划解决
 */
public class DigitalTriangleDP {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[][] nums = new int[n][n];
        int[][] dp = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < i + 1; j++) {
                nums[i][j] = scan.nextInt();
            }
        }
        dp[0][0] = nums[0][0];
        for (int i = 1; i < n; i++) {
            for (int j = 0; j < i + 1; j++) {
                if (j == 0) {
                    dp[i][j] = dp[i - 1][j] + nums[i][j];
                } else {
                    dp[i][j] = Math.max(dp[i - 1][j - 1], dp[i - 1][j]) + nums[i][j];
                }
            }
        }
        if (n % 2 != 0) {
            System.out.println(dp[n - 1][n / 2]);
        } else {
            System.out.println(Math.max(dp[n - 1][n / 2 - 1], dp[n - 1][n / 2]));
        }
    }
}
